package cn.yj.supports;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * @author 永健
 * @since 2022-02-09 10:09
 */
public class RabbitReturnCallback implements RabbitTemplate.ReturnCallback {

    private static final Logger log=LoggerFactory.getLogger(RabbitReturnCallback.class);

    /**
     * Returned message callback.
     * @param message the returned message.
     * @param replyCode the reply code.
     * @param replyText the reply text.
     * @param exchange the exchange.
     * @param routingKey the routing key.
     */
    @Override
    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        log.error("消息投递失败:message={},replyCode={},replyText={},exchange={},routingKey={}",message.toString(),replyCode,replyText,exchange,replyCode);
    }
}
